#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main()
{
    char arr[5] = "0";
    int n = 0;
    int m = 0;
    int i = 0;
    scanf("%d %d", &n, &m);
    getchar();
    for (i = 0; i < n; i++)
    {
        scanf("%c", &arr[i]);
    }
    int l;
    int r;
    char c1, c2;
    for (i = 0; i < m; i++)
    {
        scanf("%d %d %c %c", &l, &r, &c1, &c2);
        int j = 0;
        for (j = l - 1; j < r; j++)
        {
            if (c1 == arr[j])
            {
                arr[j] = c2;
            }
        }
    }
    printf("%s\n", arr);
    return 0;
}